package com.lkd.controller;


import com.lkd.entity.VmType;
import com.lkd.service.VmTypeService;
import com.lkd.vo.PageBean;
import com.lkd.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 售货机类型表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-08-20
 */
@RestController
@RequestMapping("/api/vm-service/vmType")
public class VmTypeController {

    @Autowired
    private VmTypeService vmTypeService;

    @GetMapping("/search")
    public Result search(String name,
                         @RequestParam(defaultValue = "1")Integer pageIndex,
                         @RequestParam(defaultValue = "10")Integer pageSize){
        PageBean<VmType>page=vmTypeService.search(name,pageIndex,pageSize);
        return Result.success(page);
    }

    //新增设备类型
    @PostMapping
    public Result save(@RequestBody VmType vmType){
        vmTypeService.save(vmType);
        return Result.success();
    }

    //修改设备类型
    @PutMapping
    public Result update(@RequestBody VmType vmType){
        vmTypeService.updateById(vmType);
        return Result.success();
    }

    //删除设备类型
    @DeleteMapping("/{typeId}")
    public Result delete(@PathVariable Long typeId){
        vmTypeService.removeById(typeId);
        return Result.success();
    }
}
